package charpter11.lynx;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Random;

public class Eighteen {
	public static void main(String[] args){
		HashMap<Integer,Integer> map1 = new HashMap<Integer,Integer>();
		Random rd = new Random(422);
		for (int i = 0; i < 100; i++){
			map1.put(i, rd.nextInt(422));
		}
		
		System.out.println(map1);
		
		List<Integer> keys = new ArrayList<Integer>(map1.keySet());
		Collections.sort(keys);
		
		LinkedHashMap<Integer,Integer> map2 = new LinkedHashMap<Integer,Integer>();
		for (Integer integer : keys) {
			map2.put(integer, map1.get(integer));
		}
		
		System.out.println(map2);
	}
}
